/*
 * src/port/pthread-win32.h
 */
#ifndef __PTHREAD_H
#define __PTHREAD_H

typedef struct win32_pthread
{
	HANDLE		handle;
	void	   *(*routine) (void *);
	void	   *arg;
	void	   *result;
} win32_pthread;

typedef ULONG pthread_key_t;
typedef CRITICAL_SECTION *pthread_mutex_t;
typedef int pthread_once_t;
typedef CONDITION_VARIABLE pthread_cond_t;
typedef void pthread_condattr_t;
typedef struct win32_pthread *pthread_t;
typedef int pthread_attr_t;

DWORD		pthread_self(void);
unsigned	__stdcall win32_pthread_run(void *arg);
int			pthread_create(pthread_t *thread, pthread_attr_t *attr,
						   void *(*start_routine) (void *), void *arg);
int			pthread_join(pthread_t th, void **thread_return);

void		pthread_setspecific(pthread_key_t, void *);
void	   *pthread_getspecific(pthread_key_t);

int			pthread_mutex_init(pthread_mutex_t *, void *attr);
int			pthread_mutex_lock(pthread_mutex_t *);
int			pthread_mutex_unlock(pthread_mutex_t *);	/* blocking */
int			pthread_mutex_destroy(pthread_mutex_t *);

int			pthread_cond_init(pthread_cond_t * cond, const pthread_condattr_t * attr);
int			pthread_cond_signal(pthread_cond_t * cond);
int			pthread_cond_broadcast(pthread_cond_t * cond);
int			pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t *mutex);
int			pthread_cond_destroy(pthread_cond_t *cond);

#endif
